#include<bits/stdc++.h>
using namespace std;
int s[1000000];
int main(){
freopen("color.in","r",stdin);
freopen("color.ans","w",stdout);
int t;
cin>>t;
while(t--){
int dp[100000][2];
int hash1[100000];
int n;
scanf("%d",&n);
for(int i=1;i<=n;i++){
scanf("%d",&s[i]);
hash1[s[i]]++;
}
int ans;
for(int i=1;i<=n;i++){
ans=ans+s[i]*hash1[s[i]]/2;
}
cout<<ans;
}
return 0;
}
